//年/月/日
//日/月/年
//月/日/年
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
using namespace std;
struct date
{
    int year, month, day;
    date(int _year, int _month, int _day)
        :year(_year), month(_month), day(_day) {}
    bool operator==(const date& d) const
    {
        return year == d.year && d.month == month && d.day == day;
    }
    bool operator<(const date& d) const
    {
        if(year == d.year)
        {
            if(month == d.month)
                return day < d.day;
            else
                return month < d.month;
        }
        else return year < d.year;
    }
};
int days[13] = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
vector<date> d;

bool is_leap_year(int year)
{
    return year % 400 == 0 || ((year % 4 == 0) && (year % 100 != 0));
}

void check(const string& year, const string& _month, const string& _day)
{

    string year1 = "19" + year;
    int year_1 = stoi(year1);
    int month = stoi(_month);
    // cout << month  endl;
    if(month > 12 || month <= 0) return;
    int day = stoi(_day);
    if(day <= 0) return;
    int max_day = month == 2 ? days[month] + is_leap_year(year_1) : days[month];
    if(year_1 >= 1960 && year_1 <=2059 && day <= max_day)
        d.push_back({year_1, month, day});
    string year2 = "20" + year;
    int year_2 = stoi(year2);
    max_day = month == 2 ? days[month] + is_leap_year(year_2) : days[month];
    if(year_2 >= 1960 && year_2 <= 2059 && day <= max_day)
        d.push_back({year_2, month, day});
        
}


int main()
{
    string s;
    cin >> s;
    string first = s.substr(0, 2);
    string second = s.substr(3, 2);
    string third = s.substr(6);
    check(first, second, third);
    check(third, second, first);
    check(third, first, second);
    sort(d.begin(), d.end());
    d.erase(unique(d.begin(), d.end()), d.end());
    for(const auto& e: d)
    {
        printf("%d-%02d-%02d\n", e.year, e.month, e.day);
    }
    return 0;
}